<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * role_admin 表操作方法
 * 
 * @author  : $Author: spike $
 * @date    : $Date: 2013-12-27 16:40:24 +0800 (五, 2013-12-27) $
 * @version : $Id: role_admin_dao.php 12 2013-12-27 08:40:24Z spike $
 * @rev     : $Revision: 12 $
 * @url     : $HeadURL: http://192.168.0.252/tcfs/code/application/backend/daos/role_admin_dao.php $
 */

class Role_admin_dao extends Base_Role_admin_dao
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * [分组查询多个角色的成员数量]
     * @param  [array]  $role_ids [角色id]
     * @return [array]
     */
    public function get_role_member_count(Array $role_ids)
    {
        $sql    = " SELECT `role_id`, COUNT(1) AS `count` FROM {$this->table}";
        $sql   .= " WHERE `is_delete` = ?";
        $sql   .= " AND `role_id` IN (";
        $in_str = "";
        foreach ($role_ids as $r) 
        {
           $in_str .= (int)$r.",";
        }
        $in_str = rtrim($in_str, ",");
        $sql .= $in_str." )";
        $sql .= " GROUP BY `role_id`";
        $binds = array(UNDELETED);
        
        $this->connect('read');
        $result = $this->query($sql, $binds);

        if($result)
        {
        	array_change_key($result, 'role_id');
        	return $result;
        }
        else
        {
        	return array();
        }
    }
}
/* End of file */